package com.xunqi.permission.config;

import com.sun.deploy.ui.AppInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2             //开启Swagger2
public class SwaggerConfig {

    //配置了Swagger的Dock的bean实例
    @Bean
    public Docket docket(Environment environment) {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("Jenny")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xunqi.permission.controller"))
                .paths(PathSelectors.any())
                .build();
    }


    //配置swagger信息
    private ApiInfo apiInfo() {
        //作者信息
        Contact contact =  new Contact("何杰林", "https://www.hejielin.com/", "1468041654@qq.com");
        return new ApiInfo(
                "Java开发企业级权限管理系统SwaggerAPI文档",
                "撸起袖子就是干",
                "1.0", "https://swagger.io/",
                contact, "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }

}
